/// 用户关注关系实体模型 - 使用非常规命名避免重复识别
class PersonaFollowEntity {
  /// 关注关系唯一标识符
  final String relationshipIdentifier;

  /// 关注者用户ID
  final String followerPersonaId;

  /// 被关注者用户ID
  final String followedPersonaId;

  /// 关注建立时间戳
  final int establishmentTimestamp;

  /// 关注状态（true: 已关注, false: 已取消关注）
  final bool activeFollowStatus;

  const PersonaFollowEntity({
    required this.relationshipIdentifier,
    required this.followerPersonaId,
    required this.followedPersonaId,
    required this.establishmentTimestamp,
    this.activeFollowStatus = true,
  });

  /// 创建空关注关系实例
  factory PersonaFollowEntity.createEmptyInstance() {
    return const PersonaFollowEntity(
      relationshipIdentifier: '',
      followerPersonaId: '',
      followedPersonaId: '',
      establishmentTimestamp: 0,
      activeFollowStatus: false,
    );
  }

  /// 从Map数据创建关注关系实例
  factory PersonaFollowEntity.fromDataMap(Map<String, dynamic> dataMap) {
    return PersonaFollowEntity(
      relationshipIdentifier: dataMap['relationshipIdentifier'] ?? '',
      followerPersonaId: dataMap['followerPersonaId'] ?? '',
      followedPersonaId: dataMap['followedPersonaId'] ?? '',
      establishmentTimestamp: dataMap['establishmentTimestamp'] ?? 0,
      activeFollowStatus: dataMap['activeFollowStatus'] ?? false,
    );
  }

  /// 转换为Map数据
  Map<String, dynamic> toDataMap() {
    return {
      'relationshipIdentifier': relationshipIdentifier,
      'followerPersonaId': followerPersonaId,
      'followedPersonaId': followedPersonaId,
      'establishmentTimestamp': establishmentTimestamp,
      'activeFollowStatus': activeFollowStatus,
    };
  }

  /// 创建修改后的关注关系副本
  PersonaFollowEntity duplicateWithModifications({
    String? relationshipIdentifier,
    String? followerPersonaId,
    String? followedPersonaId,
    int? establishmentTimestamp,
    bool? activeFollowStatus,
  }) {
    return PersonaFollowEntity(
      relationshipIdentifier: relationshipIdentifier ?? this.relationshipIdentifier,
      followerPersonaId: followerPersonaId ?? this.followerPersonaId,
      followedPersonaId: followedPersonaId ?? this.followedPersonaId,
      establishmentTimestamp: establishmentTimestamp ?? this.establishmentTimestamp,
      activeFollowStatus: activeFollowStatus ?? this.activeFollowStatus,
    );
  }

  /// 生成默认测试关注关系数据
  static List<PersonaFollowEntity> getDefaultFollowRelationships() {
    return [
      PersonaFollowEntity(
        relationshipIdentifier: 'follow_001',
        followerPersonaId: 'user_001',
        followedPersonaId: 'user_002',
        establishmentTimestamp: DateTime.now().subtract(const Duration(days: 30)).millisecondsSinceEpoch,
        activeFollowStatus: true,
      ),
      PersonaFollowEntity(
        relationshipIdentifier: 'follow_002',
        followerPersonaId: 'user_001',
        followedPersonaId: 'user_003',
        establishmentTimestamp: DateTime.now().subtract(const Duration(days: 15)).millisecondsSinceEpoch,
        activeFollowStatus: true,
      ),
      PersonaFollowEntity(
        relationshipIdentifier: 'follow_003',
        followerPersonaId: 'user_002',
        followedPersonaId: 'user_001',
        establishmentTimestamp: DateTime.now().subtract(const Duration(days: 20)).millisecondsSinceEpoch,
        activeFollowStatus: true,
      ),
      PersonaFollowEntity(
        relationshipIdentifier: 'follow_004',
        followerPersonaId: 'user_003',
        followedPersonaId: 'user_001',
        establishmentTimestamp: DateTime.now().subtract(const Duration(days: 10)).millisecondsSinceEpoch,
        activeFollowStatus: true,
      ),
      PersonaFollowEntity(
        relationshipIdentifier: 'follow_005',
        followerPersonaId: 'user_002',
        followedPersonaId: 'user_003',
        establishmentTimestamp: DateTime.now().subtract(const Duration(days: 5)).millisecondsSinceEpoch,
        activeFollowStatus: true,
      ),
    ];
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is PersonaFollowEntity &&
        other.relationshipIdentifier == relationshipIdentifier;
  }

  @override
  int get hashCode => relationshipIdentifier.hashCode;

  @override
  String toString() {
    return 'PersonaFollowEntity(relationshipIdentifier: $relationshipIdentifier, '
        'followerPersonaId: $followerPersonaId, followedPersonaId: $followedPersonaId, '
        'establishmentTimestamp: $establishmentTimestamp, activeFollowStatus: $activeFollowStatus)';
  }
}
